import '../mock';
import axios from 'axios';
const domain = '';
/**
 * @description 公用接口方法
 * @param url
 * @param data 参数
 * @param method POST、GET、DELETE
 * @return {promise}
 */
export default function fetchRequest(url, { data = {}, method = 'GET' }) {
    switch (method) {
        case 'GET': {
            return axios.get(url).then(result => {
                console.log(result)
                if (result.data.code > 0) {
                    return result.data;
                } else {
                    return Promise.reject();
                }
            });
        }
        case 'POST': {
            return axios.post(url).then(result => {
                console.log(result.data)
                if (result.data.code > 0) {
                    return result.data;
                } else {
                    return Promise.reject();
                }
            });
        }
    }
}
